package main
// Sqrt calculate the square root of a non-negative float64 
// number with max error of 10^-9. For simplicity, we don't 
// discard the part with is smaller than 10^-9.
func Sqrt(x float64) float64 {
	if x < 0 {
	  panic("cannot be negative")
	}
  
	if x == 0 {
	  return 0
	}
  
	a := x / 2
	b := (a + 2) / 2
	erro := a - b
	for erro >= 0.000000001 || erro <= -0.000000001 {
	  a = b
	  b = (b + x/b) / 2
	  erro = a - b
	}
	return b
  }